package com.bootcamp.java;

import java.util.Scanner;

/**
 * @program: ArrayCode
 * @description: get 10 students score from keyboard input and calculate their average score.
 * @author: Keyu Li
 * @create: 2021-08-26 19:17
 **/

public class StudentScore {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double[] scores = new double[10];
        for (int i = 0; i < 10; i++) {
            System.out.print("Please input " + (i + 1) + "th student score: ");
            scores[i] = Double.parseDouble(sc.nextLine());
        }
        System.out.println("the average score is " + averageScore(scores));
    }

    private static double averageScore(double[] scores) {
        double sum = 0.0;
        for (double score : scores) {
            sum += score;
        }
        return sum / scores.length;
    }
}
